package com.kefu.call.controller;

import com.kefu.call.model.IvrComVo;
import com.kefu.call.service.CallIvrComService;
import com.kefu.call.vo.CallIvrComInsertVo;
import com.kefu.call.vo.CallIvrComUpdateVo;
import com.kefu.common.controller.AbstractBaseController;
import com.kefu.common.result.Result;
import com.kefu.common.result.ResultGenerator;
import com.kefu.common.vo.DeleteVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "ivr设置")
@RestController
@RequestMapping("call/ivrCom")
public class CallIvrComController extends AbstractBaseController {

    @Autowired
    CallIvrComService callIvrComService;

    @PostMapping("/list")
    @ApiOperation(value = "查询")
    public Result<List<IvrComVo>> list() {
        return ResultGenerator.genSuccessResult(callIvrComService.queryList());
    }

    @PostMapping("/add")
    @ApiOperation(value = "增加")
    public Result<String> add(@Validated @RequestBody CallIvrComInsertVo insertVo) {
        logger.info("增加:{}", insertVo);

        callIvrComService.add(insertVo);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改")
    public Result<String> update(@Validated @RequestBody CallIvrComUpdateVo updateVo) {
        logger.info("修改ivr:{}", updateVo);
        callIvrComService.update(updateVo);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除")
    public Result<String> delete(@Validated @RequestBody DeleteVo deleteVo) {
        logger.info("删除:{}", deleteVo);

        callIvrComService.removeById(deleteVo.getId());
        return ResultGenerator.genSuccessResult();
    }



}
